package bairui.international.weixin.portal.miniapp.controller.user;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_User;
import bairui.international.service.Service_User;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 *
 * 账户操作
 *
 * @generated
 * 
 * @see STest_C_User_Account_Get 测试
 *
 */
@Controller
public class C_User_Account_Get
 extends SC_User_Account_Get 
{
	
	@Autowired private Service_User service_User;
	
	/**
	 * 获取
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request,
		@RequestParam String skey
	) throws Exception {
		TB_User user = service_User.findOne(it->it.skey.eq(skey));
		//
		return new Output(user);
	}
	
	@AllArgsConstructor
	public static class Output {
		private @Getter String name;
		private @Getter String phone;
		private @Getter String company;
		private @Getter String accountNumber;
		private @Getter String bank;
		
		public Output(TB_User user){
			this.name = null == user.getRealName() ? "" : user.getRealName();
			this.phone = null == user.getPhone() ? "" : user.getPhone();
			this.company = null == user.getCompany() ? "" : user.getCompany();
			this.accountNumber = null == user.getAccountNumber() ? "" : user.getAccountNumber();
			this.bank = null == user.getBank() ? "" : user.getBank();
		}
	}

}
